(function(g, f) {
    function y(b) {
        if (b) return b.replace(/^\s+|\s+$/g, "")
    }
    function w(b, l) {
        if (!b) return {};
        var a = "INFO" === l.logLevel;
        b.m && b.m.message && (b = b.m);
        var e = l.m || l.message || "",
        e = b.m && b.m.message ? e + b.m.message: b.m && b.m.target && b.m.target.tagName ? e + ("Error handler invoked by " + b.m.target.tagName + " tag") : b.m ? e + b.m: b.message ? e + b.message: e + "Unknown error",
        e = {
            m: e,
            name: b.name,
            type: b.type,
            csm: N + " " + (b.fromOnError ? "onerror": "ueLogError")
        },
        k,
        f,
        h = 0,
        q;
        e.logLevel = l.logLevel || A;
        l.adb && (e.adb = l.adb);
        if (k = l.attribution) e.attribution = "" + k;
        if (!a) {
            e.pageURL = l.pageURL || "" + (window.location ? window.location.href: "") || "missing";
            e.f = b.f || b.sourceURL || b.fileName || b.filename || b.m && b.m.target && b.m.target.src;
            e.l = b.l || b.line || b.lineno || b.lineNumber;
            e.c = b.c ? "" + b.c: b.c;
            e.s = [];
            e.t = g.ue.d();
            if ((a = b.stack || (b.err ? b.err.stack: "")) && a.split) for (e.csm += " stack", k = a.split("\n"); h < k.length && e.s.length < F;)(a = k[h++]) && e.s.push(y(a));
            else for (e.csm += " callee", f = z(b.args || arguments, "callee"), k = h = 0; f && h < F;) q = G,
            f.skipTrace || (a = f.toString()) && a.substr && (q = 0 === k ? 4 * G: q, q = 1 == k ? 2 * G: q, e.s.push(a.substr(0, q)), k++),
            f = z(f, "caller"),
            h++;
            if (!e.f && 0 < e.s.length && (h = e) && h.s) {
                var n, a = 0 < h.s.length ? h.s[0] : "";
                k = 1 < h.s.length ? h.s[1] : "";
                a && (n = a.match(x));
                n && 3 == n.length || !k || (n = k.match(O));
                n && 3 == n.length && (h.f = n[1], h.l = n[2])
            }
        }
        return e
    }
    function z(b, g) {
        try {
            return b[g]
        } catch(a) {}
    }
    function B(b, l) {
        if (b) {
            for (var a = w(b, l), e = (window.ue_err ? window.ue_err.errorHandlers: null) || [], k = 0; k < e.length; k++)"function" == typeof e[k].handler && e[k].handler(a);
            g.ue.log(a, l.channel || K, {
                nb: 1
            });
            "function" === typeof ue_err.elh && ue_err.elh(b, l);
            try {
                if (!b.fromOnError) {
                    var r = f.console,
                    h = f.JSON,
                    e = "Error logged with the Track\x26Report JS errors API(http://tiny/1covqr6l8/wamazindeClieUserJava): ";
                    if (r) {
                        if (h && h.stringify) try {
                            e += h.stringify(a)
                        } catch(q) {
                            e += "no info provided; converting to string failed"
                        } else e += a.m;
                        "function" === typeof r.error ? r.error(e, a) : "function" === typeof r.log && r.log(e, a)
                    }
                }
            } catch(q) {}
        }
    }
    function C(b, l) {
        if (b && !(g.ue_err.ec > g.ue_err.mxe)) {
            g.ue_err.ter.push(b);
            l = l || {};
            var a = b.logLevel || l.logLevel;
            l.logLevel = a;
            l.attribution = b.attribution || l.attribution;
            a && a !== A && a !== L && a !== D && a !== H || g.ue_err.ec++;
            a && a != A || ue_err.ecf++;
            B(b, l)
        }
    }
    if (g.ue_err && (!g.ueLogError || g.ueLogError.isStub)) {
        var K = g.ue_err_chan || "jserr",
        A = "FATAL",
        L = "ERROR",
        D = "WARN",
        H = "DOWNGRADED",
        N = "v5",
        F = 20,
        G = 256,
        O = /\(?([^\s]*):(\d+):\d+\)?/,
        x = /.*@(.*):(\d*)/;
        B.skipTrace = 1;
        w.skipTrace = 1;
        C.skipTrace = 1; (function() {
            if (g.ue_err.erl) {
                var b = g.ue_err.erl.length,
                l, a;
                for (l = 0; l < b; l++) a = g.ue_err.erl[l],
                B(a.ex, a.info);
                ue_err.erl = []
            }
        })();
        g.ueLogError = C
    }
})(ue_csm, window); (function(g, f) {
    function y(u) {
        for (var b = {},
        c, d, m = 0; m < u.length; m++) d = u[m],
        d.r = d.r || a.rid,
        d.s = d.s || g.ue_sid,
        c = d.r + d.s + d.m,
        d.c && (b[c] || (b[c] = []), b[c].push(u[m]));
        return b
    }
    function w(a) {
        for (var b = 1; b < arguments.length; b++) {
            var c = arguments[b];
            try {
                if (c.isSupported) return c.send(a)
            } catch(d) {}
        }
    }
    function z() {
        if (k.length && !a.paused) {
            for (var b = 0; b < h.length; b++) h[b]();
            a._flhs += 1;
            B();
            w(y(k.splice(0, k.length)), I, J, E)
        }
        n = P = 0
    }
    function B() {
        G && C({
            k: "chk",
            f: a._flhs,
            l: a._lpn,
            s: "full"
        },
        "csm")
    }
    function C(b, v, c) {
        c = c || {}; ! g.ue_furl || 0 === c.bf && a.isBF || (b = {
            r: c.r || (a.paused ? void 0 : a.rid),
            s: c.s || (a.paused ? void 0 : g.ue_sid),
            m: c.m || g.ue_mid,
            mkt: c.mkt || g.ue_mkt,
            sn: c.sn || g.ue_sn,
            c: v,
            d: b,
            t: c.t || a.d(),
            cs: c.c && g.ue_qsl
        },
        a._lpn[v] = (a._lpn[v] || 0) + 1, c.b ? w(y([b]), I, E) : c.nb ? w(y([b]), I, J, E) : c.img || R[v] ? w(y([b]), E) : c.ff ? (k.push(b), z()) : c.n ? (k.push(b), 0 === Q ? z() : n || (n = f.setTimeout(z, Q))) : (k.push(b), P || (P = f.setTimeout(z, S))))
    }
    function K(b, a, c) {
        M++;
        M == F && C({
            m: "Max number of Forester Logs exceeded",
            f: "forester-client.js",
            logLevel: "ERROR"
        },
        f.ue_err_chan || "jserr"); (M < F || c && c.il) && C(b, a, c)
    }
    function A() {
        if (!q) {
            for (var b = 0; b < r.length; b++) r[b]();
            for (b = 0; b < h.length; b++) h[b]();
            a._flhs += 1;
            B();
            w(y(k.splice(0, k.length)), I, E);
            q = !0
        }
    }
    function L(a) {
        var v = b(a);
        a.reqs && (v = {
            csmcount: {
                counter: O,
                t: 0,
                value: v.length
            }
        },
        v.csmcount.value += b(v).length, a.reqs.push(v), v = b(a));
        return v
    }
    var D = {}; (function() {
        function b(a) {
            return 10 > a ? "0" + a: a
        }
        function a(b) {
            d.lastIndex = 0;
            return d.test(b) ? '"' + b.replace(d,
            function(b) {
                var a = e[b];
                return "string" === typeof a ? a: "\\u" + ("0000" + b.charCodeAt(0).toString(16)).slice( - 4)
            }) + '"': '"' + b + '"'
        }
        function c(b, d) {
            var e, u, l = m,
            p, f = d[b];
            f && "object" === typeof f && "function" === typeof f.toJSON && (f = f.toJSON(b));
            "function" === typeof k && (f = k.call(d, b, f));
            switch (typeof f) {
            case "string":
                return a(f);
            case "number":
                return isFinite(f) ? String(f) : "null";
            case "boolean":
            case "null":
                return String(f);
            case "object":
                if (!f) return "null";
                m += g;
                p = [];
                if ("[object Array]" === Object.prototype.toString.apply(f)) {
                    d = f.length;
                    for (b = 0; b < d; b += 1) p[b] = c(b, f) || "null";
                    u = 0 === p.length ? "[]": m ? "[\n" + m + p.join(",\n" + m) + "\n" + l + "]": "[" + p.join(",") + "]";
                    m = l;
                    return u
                }
                if (k && "object" === typeof k) for (d = k.length, b = 0; b < d; b += 1)"string" === typeof k[b] && (e = k[b], (u = c(e, f)) && p.push(a(e) + (m ? ": ": ":") + u));
                else for (e in f) Object.prototype.hasOwnProperty.call(f, e) && (u = c(e, f)) && p.push(a(e) + (m ? ": ": ":") + u);
                u = 0 === p.length ? "{}": m ? "{\n" + m + p.join(",\n" + m) + "\n" + l + "}": "{" + p.join(",") + "}";
                m = l;
                return u
            }
        }
        "function" !== typeof Date.prototype.toJSON && (Date.prototype.toJSON = function(a) {
            return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + b(this.getUTCMonth() + 1) + "-" + b(this.getUTCDate()) + "T" + b(this.getUTCHours()) + ":" + b(this.getUTCMinutes()) + ":" + b(this.getUTCSeconds()) + "Z": null
        },
        String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(b) {
            return this.valueOf()
        });
        var d = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        m, g, e = {
            "\b": "\\b",
            "\t": "\\t",
            "\n": "\\n",
            "\f": "\\f",
            "\r": "\\r",
            '"': '\\"',
            "\\": "\\\\"
        },
        k;
        "function" !== typeof D.stringify && (D.stringify = function(b, a, d) {
            var e;
            g = m = "";
            if ("number" === typeof d) for (e = 0; e < d; e += 1) g += " ";
            else "string" === typeof d && (g = d);
            if ((k = a) && "function" !== typeof a && ("object" !== typeof a || "number" !== typeof a.length)) throw Error("JSON.stringify");
            return c("", {
                "": b
            })
        })
    })();
    var H = function() {
        function b(a, c) {
            if (null == a) return c.push("!n");
            if ("number" === typeof a) return c.push("!" + a);
            if ("string" === typeof a) return "\\" == a[a.length - 1] ? c.push("'" + a.replace(/'/g, "\\'") + "u005C'") : c.push("'" + a.replace(/'/g, "\\'") + "'");
            if ("boolean" === typeof a) return c.push(a ? "!t": "!f");
            if (a instanceof Array) {
                c.push("*");
                for (var d = 0; d < a.length; d++) b(a[d], c);
                return c.push(")")
            }
            if ("object" == typeof a) {
                c.push("(");
                for (d in a) a.hasOwnProperty(d) && (c.push(d), b(a[d], c));
                return c.push(")")
            }
            return c.push("!n")
        }
        return {
            stringify: function(a) {
                var c = [];
                b(a, c);
                return c.join("")
            }
        }
    } (),
    N = g.ue_qsl || 2E3,
    F = 2E3,
    G = 1 === window.ue_ddq,
    O = "foresterPayloadSize",
    x = function() {},
    b = f.JSON && f.JSON.stringify || D && D.stringify,
    l = H.stringify,
    a = g.ue || {},
    H = g.uet || x; (g.uet || x)("bb", "ue_frst_v2", {
        wb: 1
    });
    var e = "//" + g.ue_furl + "/1/batch/1/OE/",
    k = [],
    r = [],
    h = [],
    q = !1,
    n,
    P,
    Q = void 0 === g.ue_hpfi ? 1E3: g.ue_hpfi,
    S = void 0 === g.ue_lpfi ? 1E4: g.ue_lpfi,
    R = {
        "scheduled-delivery": 1
    },
    M = 0,
    J = function() {
        function b() {
            if (f.XDomainRequest) {
                var a = new XDomainRequest;
                a.onerror = x;
                a.ontimeout = x;
                a.onprogress = x;
                a.onload = x;
                a.timeout = 0;
                return a
            }
            if (f.XMLHttpRequest) {
                a = new XMLHttpRequest;
                if (! ("withCredentials" in a)) throw "";
                return a
            }
            if (f.ActiveXObject) {
                for (var c = 0; c < d.length && !a; c++) try {
                    a = new ActiveXObject(d[c]),
                    d = [d[c]]
                } catch(e) {}
                return a
            }
        }
        function l(b) {
            for (var c = [], d = b[0] || {},
            e = 0; e < b.length; e++) {
                var f = {};
                f[b[e].c] = b[e].d;
                c.push(f)
            }
            return {
                rid: d.r || a.rid,
                sid: d.s || g.ue_sid,
                mid: d.m || g.ue_mid,
                mkt: d.mkt || g.ue_mkt,
                sn: d.sn || g.ue_sn,
                reqs: c
            }
        }
        function c(a) {
            var c = l(a),
            d = b();
            if (!d) throw "";
            d.onerror = function() {
                for (var b = 0; b < a.length; b++) k.push(a[b]);
                J.isSupported = !1
            };
            d.open("POST", e, !0);
            d.setRequestHeader && d.setRequestHeader("Content-type", "text/plain");
            c = L(c);
            d.send(c)
        }
        var d = "MSXML2.XMLHTTP.6.0 MSXML2.XMLHTTP.5.0 MSXML2.XMLHTTP.4.0 MSXML2.XMLHTTP.3.0 MSXML2.XMLHTTP Microsoft.XMLHTTP".split(" ");
        return {
            send: function(a) {
                for (var b in a) a.hasOwnProperty(b) && a[b].length && c(a[b])
            },
            buildPOSTBodyLog: l,
            isSupported: !0
        }
    } (),
    E = function() {
        return {
            send: function(f) {
                for (var k in f) if (f.hasOwnProperty(k)) {
                    for (var c = f[k], d = c, m = {},
                    h, p = 0; p < d.length; p++) h = d[p].c,
                    m[h] || (m[h] = []),
                    m[h].push(d[p]);
                    c = c[0] || {};
                    d = c.sn || g.ue_sn;
                    c = e + (c.m || g.ue_mid) + ":" + (c.s || g.ue_sid) + ":" + (c.r || a.rid) + (d ? ":" + d: "");
                    d = [];
                    h = c;
                    var p = [],
                    n = void 0;
                    for (n in m) if (m.hasOwnProperty(n)) for (var t = 0; t < m[n].length; t++) {
                        var q = m[n][t],
                        r = encodeURIComponent((q.cs ? l: b)(q.d));
                        p.push({
                            l: r,
                            t: q.t,
                            p: 1,
                            c: n,
                            d: q.cs ? "c": "j"
                        })
                    }
                    m = p;
                    p = void 0;
                    n = "$";
                    for (q = 0; q < m.length;) {
                        t = m[q];
                        p != t.c ? (h += n + t.c + "\x3d", n = "\x26", p = t.c) : h += ",";
                        var r = h,
                        x = t.d + ":",
                        w = t;
                        h = (w.l.match(".{1," + (N - h.length) + "}[^%]{0,2}") || [])[0] || "";
                        w.l = w.l.substr(h.length);
                        h = r + (x + h + ":" + t.t);
                        if (t.l) h += ":" + t.p+++"_",
                        d.push(h),
                        h = c,
                        n = "$",
                        p = 0;
                        else if (q++, 1 != t.p) for (h += ":" + t.p + "_" + t.p, r = 0; r < t.p - 1; r++) d[d.length - r - 1] += t.p
                    }
                    d.push(h);
                    c = d;
                    for (d = 0; d < c.length; d++)(new Image).src = c[d]
                }
            },
            isSupported: !0
        }
    } (),
    I = function() {
        return {
            send: function(a) {
                for (var b in a) if (a.hasOwnProperty(b)) {
                    var c = J.buildPOSTBodyLog(a[b]),
                    c = L(c);
                    if (!navigator.sendBeacon(e, c)) throw "";
                }
            },
            isSupported: !!navigator.sendBeacon
        }
    } ();
    a._fic = E;
    a._fac = J;
    a._fbc = I;
    a._flq = k;
    a.sid = a.sid || g.ue_sid;
    a.mid = a.mid || g.ue_mid;
    a.furl = a.furl || g.ue_furl;
    a.sn = a.sn || g.ue_sn;
    a._flhs = a._flhs || 0;
    a._lpn = a._lpn || {};
    try {
        f.amznJQ && f.amznJQ.declareAvailable && f.amznJQ.declareAvailable("forester-client"),
        f.P && f.P.register && f.P.register("forester-client", x)
    } catch(u) {
        g.ueLogError(u, {
            logLevel: "WARN"
        })
    } (function() {
        a.log && a.log.isStub && (a.log.replay(function(a, b, c) {
            var d = a[2] || {};
            d.t = b;
            d.r = c;
            d.n = 1;
            K(a[0], a[1], d)
        }), a.onunload.replay(function(a) {
            r.push(a[0])
        }), a.onflush.replay(function(a) {
            h.push(a[0])
        }))
    })();
    a.log = K;
    a.log.reset = function() {
        M = 0
    };
    a.onunload = function(a) {
        r.push(a)
    };
    a.onflush = function(a) {
        h.push(a)
    };
    a.attach("beforeunload", A);
    a.attach("pagehide", A);
    H("ld", "ue_frst_v2", {
        wb: 1
    })
})(ue_csm, window);